package com.plugin.uniapp.dialog;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.plugin.uniapp.R;
import com.plugin.uniapp.utils.Logger;

public class BaseView {
    public boolean isVisible;
    protected MultiViewDialog dialog;
    protected LinearLayout layout;
    protected  LayoutInflater inflater;

    public BaseView(MultiViewDialog dialog, int sourceId) {
        this.dialog = dialog;
        inflater = LayoutInflater.from(this.dialog.getContext());
        FrameLayout container = this.dialog.findViewById(R.id.fragment_container);
        layout = (LinearLayout) inflater.inflate(sourceId, container, false);
        container.addView(layout);
        isVisible = layout.getVisibility() == View.VISIBLE;
    }

    public void show() {
        isVisible = true;
        layout.setVisibility(View.VISIBLE);
    }

    public void hide() {
        isVisible = false;
        layout.setVisibility(View.INVISIBLE);
    }

    protected void log(String msg) {
        Logger.log(msg, getClass(), false);
    }

    protected void error(String msg) {
        Logger.error(msg, getClass(), false);
    }
}
